<template>
  <div>
    <span>文章标题</span><input type="title" v-model="title" />
    <span>是否公开</span
    ><input type="checkbox" id="checkbox" v-model="checked" />
    <span>文章内容</span><input type="text" v-model="content" />
    <button @click="fabufn">发布</button>
    <button @click="Czfn">重置</button>
  </div>
</template>
<script>
import http from "@/utils/http";
export default {
  data() {
    return {
      title: "",
      content: "",
      checked: "",
    };
  },
  methods: {
    async fabufn() {
      let r = await http({
        url: "/posts",
        method: "post",
        data: {
          title: this.title,
          content: this.content,
          status: Boolean(this.checked),
        },
      }).then((r) => console.log(r.data));
    },
    Czfn() {
      this.title = "";
      this.content = "";
      this.checked = false;
    },
  },
};
</script>
<style lang=""></style>
